<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-lx-calendar"></i>财务管理</el-breadcrumb-item>
				<el-breadcrumb-item>UPH兑换开关</el-breadcrumb-item>
            </el-breadcrumb>
        </div>

		<div class="container">
			<el-row>
				<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
					<el-form ref="form" :model="form" label-width="100px">

						<el-form-item label="状态">
							<el-radio v-model="form.state" label="1">开启</el-radio>
							<el-radio v-model="form.state" label="2">关闭</el-radio>
						</el-form-item>
						<!-- <el-form-item label="登录密码 ">
							<el-input v-model="form.loginpwd" placeholder="请输入您的登录密码" ></el-input>
						</el-form-item> -->

                        <el-form-item label="">
                            <el-button :loading="ifload" type="primary" @click="saveData">保存</el-button>
                        </el-form-item>
					</el-form>
				</el-col>
			</el-row>
		</div>

		<loading :ifload="ifload"></loading>
	</div>
</template>

<script type="text/javascript">
	import loading from '@/components/utils/loading';
	export default{
		components:{loading},
		data() {
			return {
				ifload:true,

                member_id:'',

				form:{
                    state: '',
                    loginpwd: '',
                },
			}
		},
		created() {
			this.$nextTick(()=>{
				this.getData();
			})
		},
		methods: {
			getData() {
                this.ifload = true;
                let param = {};
                this.$post_('finance/setting/exchange-switch',param,(res) => {
                    console.log(res);
                    if(res.code=='0'){
                        this.form.state = res.data.value;
                    }
                })
				this.ifload = false;
			},
            //保存数据
            saveData() {
                // this.form.member_id = this.member_id;
                if(!this.isNumber(this.form.state)){
                    console.log('111111111111');
                    this.$message.error('状态不能为空');
                }else{
                    this.ifload = true;
                    console.log('2222222222222');
                    this.$post_('finance/setting/edit-exchange-switch',this.form,(res) =>{
                        console.log(res);
                        this.ifload = false;
                        if(res.code=='0'){
                            this.$message.success(res.msg);
                            // this.$router.back(-1);
                        }else{
                            this.$message.error(res.msg);
                        }
                    })
                }
            },
            isNumber(val) {
            　　if (parseFloat(val).toString() == "NaN") {
            　　　　
            　　　　return false;
            　　} else {
            　　　　var re = /^\d+(\.\d+)?$/;//判断字符串是否为数字//判断正整数/[1−9]+[0−9]∗]∗/
                　　if (!re.test(val)) {
                　　　　return false;
                　　}
                    return true;
            　　}
            }
		}
	}
</script>

<style scoped="scoped">
</style>
